package soar.test.image;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Random;

public class WeatherData
{
	public class Day
	{
		public String date;
		public String day;
		public String desc_code = "";
		public String air_temperature = "";
	}

	public Day[] days;

	public HashMap<String, String> indexes;

	public WeatherData()
	{
		SimpleDateFormat date_format = new SimpleDateFormat("M月d日");
		date_format.setLenient(false);
		SimpleDateFormat day_format = new SimpleDateFormat("E");
		day_format.setLenient(false);

		Calendar cal = new GregorianCalendar();
		cal.setTime(new Date());

		this.days = new Day[4];
		for (int i = 0; i < days.length; ++i)
		{
			Day day = new Day();
			day.date = date_format.format(cal.getTime());
			day.day = day_format.format(cal.getTime());
			this.days[i] = day;
			cal.add(Calendar.DATE, 1);
		}

		HashMap<String, String> indexes = new HashMap<String, String>();
		indexes.put("穿衣指数", "");
		indexes.put("感冒指数", "");
		indexes.put("空气质量指数", "");
		indexes.put("洗车指数", "");
		indexes.put("运动指数", "");
		indexes.put("紫外线指数", "");
		this.indexes = indexes;
	}

	public void random()
	{
		Random rand = new Random();
		String[] desc_code_s = WeatherDesc.getAllCode();
		for (WeatherData.Day day : days)
		{
			day.desc_code = desc_code_s[rand.nextInt(desc_code_s.length)];
			int low = rand.nextInt(40) - 10;
			int high = rand.nextInt(40) - 10;
			if (low > high)
			{
				int a = low;
				low = high;
				high = a;
			}
			day.air_temperature = String.format("%d/%d°C", low, high);
		}
	}
}
